package com.salt.modules.sys.service;


import com.salt.common.service.CrudService;
import com.salt.common.utils.IdGen;
import com.salt.core.persistence.Page;
import com.salt.modules.sys.entity.BackgroundIconFiles;
import com.salt.modules.sys.mapper.BackgroundIconFilesMapper;
import org.joda.time.DateTime;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.CrossOrigin;

import javax.annotation.Resource;

/**
 * (GeneralSignFiles)表服务实现类
 *
 * @author makejava
 * @since 2020-12-09 10:50:57
 */
@Service
@CrossOrigin
@Transactional(readOnly = false)
public class BackgroundIconFilesService extends CrudService<BackgroundIconFilesMapper, BackgroundIconFiles> {
    @Resource
    private BackgroundIconFilesMapper backgroundIconFilesMapper;


    /**
     * 通过ID查询单条数据
     *
     * @param id 主键
     * @return 实例对象
     */

    public BackgroundIconFiles queryById(String id) {
        return this.backgroundIconFilesMapper.queryById(id);
    }

    /**
     * 分页数据
     * @return 对象列表
     */
    public Page<BackgroundIconFiles> findPage(Page<BackgroundIconFiles> page, BackgroundIconFiles backgroundIconFiles) {
        return super.findPage(page, backgroundIconFiles);
    }

    /**
     * 新增数据
     * @param  backgroundIconFiles 实例对象
     * @return 实例对象
     */
    public BackgroundIconFiles saveFile(BackgroundIconFiles backgroundIconFiles) {

        backgroundIconFiles.setId(IdGen.uuid());

        backgroundIconFiles.setUploadTime(new DateTime().toString("yyyy-MM-dd HH:mm:ss"));
        backgroundIconFilesMapper.insert(backgroundIconFiles);
        return backgroundIconFiles;
    }


    /**
     * 通过主键删除数据
     *
     * @param id 主键
     * @return 是否成功
     */
    public boolean deleteById(String id) {
        return this.backgroundIconFilesMapper.deleteById(id) > 0;
    }

    public void update(BackgroundIconFiles backgroundIconFiles) {
        backgroundIconFilesMapper.update(backgroundIconFiles);
    }
}